import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @program: spring-demo2
 * @author: JCM
 * @create: 2023-06-11 14:21
 * @description:
 **/
public class App {
    public static void main(String[] args) {
        // 1. 先得到 Spring 对象
        ApplicationContext context =
                new ClassPathXmlApplicationContext("spring.xml");

        // 2. 从 Spring 中取出 Bean 对象
        User user = (User) context.getBean("user");
        User user1 = (User) context.getBean("user");
        // user 和 user1 是同一个对象
        System.out.println(user);
        System.out.println(user1);
        System.out.println(user == user1);

        System.out.println("========================");
        User user2 = (User) context.getBean("user2");
        // user 和 user2 不是一个对象
        System.out.println(user);
        System.out.println(user2);
        System.out.println(user == user2);

        // 3. 使用 Bean
        //System.out.println(user.sayHi());


        
    }
}
